/*
 * @Author       : 魏威 <1209562577@qq.com>
 * @Date         : 2021-08-25 19:32 周3
 * @Description  : useArray hook测试组件
 */
import { useArray } from 'hooks/useArray';
import React, { useEffect } from 'react';

interface Person {
  name: string;
  age: number;
}

export default function TryUseArray() {
  const personArr: Person[] = [
    { name: 'waker', age: 22 },
    { name: 'cn', age: 21 }
  ];
  const { value, add } = useArray(personArr);

  useEffect(() => {
    console.log(value);
    add({ name: 'ys', age: 30 });
    // eslint-disable-next-line
  }, []);

  return (
    <div>
      {value.map((item, index) => (
        <div key={index}>{item.name}</div>
      ))}
    </div>
  );
}
